package com.qianxx.viewlibrary.recyclerview.ainm;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.AttributeSet;

public class AnimRFStaggeredGridLayoutManager extends
		StaggeredGridLayoutManager {

	private OverScrollListener mListener;

	public AnimRFStaggeredGridLayoutManager(Context context,
											AttributeSet attrs, int defStyleAttr, int defStyleRes) {
		super(defStyleAttr, defStyleRes);
	}

	public AnimRFStaggeredGridLayoutManager(int spanCount, int orientation) {
		super(spanCount, orientation);
	}

	@Override
	public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler,
								  RecyclerView.State state) {
		int scrollRange = super.scrollVerticallyBy(dy, recycler, state);

		mListener.overScrollBy(dy - scrollRange);

		return scrollRange;
	}

	/**
	 * 设置滑动过度监听
	 *
	 * @param listener
	 */
	public void setOverScrollListener(OverScrollListener listener) {
		mListener = listener;
	}

}
